import item from "element-plus/es/components/space/src/item"
import { defineStore } from "pinia"

export const useUserStore = defineStore("user", {
    state(): {
        menus: IMenu[]
    } {
        return {
            menus: []
        }
    },
    getters: {
        activeMenus() {
            //先找出一级菜单
            let arr: IActiveMenus[] = this.menus.filter((item) => item.parentId === 0)
            //找出所有对应一级菜单，防到二级菜单的children数组里面
            this.menus.forEach((item)=> {
    let p = arr.find((p) => p.id === item.parentId && item.hidden === 0);
    if (p) {
        if (!p.children) {
            p.children = []
        }
        p.children.push(item)

    }

});
return arr
        }
    }
})